package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.front.pojo.TbContent;
import com.dongdongshop.front.pojo.TbContentExample;
import com.dongdongshop.front.service.ContentService;
import com.dongdongshop.mapper.TbContentMapper;
import com.dongdongshop_util.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.List;

@Service
@Component
public class ContentServiceImpl implements ContentService {

    @Autowired
    private TbContentMapper contentMapper;

    @Override
    public List<TbContent> getContentByContentIdAndNumber(Long categoryId, Integer number) {
        List<TbContent> contentList = contentMapper.getContentByContentIdAndNumber(categoryId,number);
        return contentList;
    }

    @Override
    public List<TbContent> getContent() {
        List<TbContent> contentList = contentMapper.selectByExample(new TbContentExample());
        return contentList;
    }

    @Override
    public void addContent(TbContent content) {
        contentMapper.insertSelective(content);
    }

    @Override
    public void updateContent(TbContent content) {
        contentMapper.updateByPrimaryKey(content);
    }

    @Override
    public TbContent getContentById(Long id) {
        TbContent content = contentMapper.selectByPrimaryKey(id);
        return content;
    }

    @Override
    public void deleteContent(Long[] ids) {
        contentMapper.deleteContent(ids);
    }
}
